package com.youlu.campus.admin.item;

import com.youlu.campus.common.base.RestResult;
import com.youlu.campus.common.base.RestResultBuilder;
import com.youlu.campus.entity.ActivityBadgeRule;
import com.youlu.campus.entity.VO.req.ItemQueryReq;
import com.youlu.campus.service.item.ActivityBadgeRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * 活动徽章管理
 */
@RestController
public class ActivityBadgeRuleController {

    @Autowired
    private ActivityBadgeRuleService activityBadgeRuleService;

    @PostMapping("/activity/badge/save")
    public RestResult save(@RequestBody @NotNull ActivityBadgeRule activityBadgeRule) {
        activityBadgeRuleService.saveOrUpdate(activityBadgeRule);
        return RestResultBuilder.builder().success().data(null).build();
    }

    @PostMapping("/activity/badge/list")
    public RestResult list(@RequestBody ItemQueryReq itemQueryReq) {
        return RestResultBuilder.builder().success().data(activityBadgeRuleService.list(itemQueryReq)).build();
    }

    @GetMapping("/activity/badge/detail")
    private RestResult detail(@RequestParam String id) {
        return RestResultBuilder.builder().success().data(activityBadgeRuleService.detail(id)).build();
    }

    @GetMapping("/activity/badge/delete")
    private RestResult delete(@RequestParam String id) {
        return RestResultBuilder.builder().success().data(activityBadgeRuleService.delete(id)).build();
    }
}
